<template>
	<view class="apply">
		<view class="item" v-for="(item, index) in deliveryList" :key="index" @click="toPage(item)">
			<view class="title">
				<text>{{ item.jobName }}</text>
				<view class="tpis" v-show="item.status !== 2"></view>
			</view>
			<view class="user-info">
				<view class="wrap">
					<text>{{ item.name }}</text>
					<text class="line"></text>
					<text>{{ item.sex }}</text>
					<text class="line"></text>
					<text>{{ calculateAge(item.birth) }}</text>
					<text class="line"></text>
					<text>本科</text>
				</view>
				<view class="wrap bottom">
					<view class="info">
						<view class="avatar"><image :src="item.avatar" mode="aspectFill"></image></view>
						<text class="name">{{ item.nickname }}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { getDeliveryUserList, updateDeliveryStatus } from '@/apis/delivery/index.js';

export default {
	data() {
		return {
			deliveryList: []
		};
	},
	onShow() {
		this.initData();
	},
	methods: {
		async initData() {
			const id = this.$store.state.userInfo.id;
			const res = await getDeliveryUserList(id);
			this.deliveryList = res.data;
			this.deliveryList.sort((a, b) => {
				return a.status - b.status;
			});
		},
		// 计算年龄
		calculateAge(date) {
			const birth = new Date(date).getFullYear();
			const year = new Date().getFullYear();
			return year - birth;
		},
		toPage(row) {
			uni.setStorageSync('resume', JSON.stringify(row));
			uni.navigateTo({ url: '/pages/company/resume-detail' });
		}
	}
};
</script>

<style lang="scss" scoped>
.line {
	width: 4rpx;
	height: 20rpx;
	margin: 0 15rpx;
	background-color: #ccc;
}

text {
	font-size: 30rpx;
}

.apply {
	padding: 20rpx;
	.item {
		padding: 20rpx 30rpx;
		margin-bottom: 20rpx;
		border-radius: 16rpx;
		background-color: #fff;
		.title {
			display: flex;
			justify-content: space-between;
			& > text {
				font-size: 36rpx;
				font-weight: bold;
				color: $main-color;
			}
			.tpis {
				width: 20rpx;
				height: 20rpx;
				border-radius: 20rpx;
				background-color: #e45656;
			}
		}
		.wrap {
			display: flex;
			align-items: center;
			margin: 20rpx 0 20rpx;
			text {
				font-size: 30rpx;
			}
			&.bottom {
				justify-content: space-between;
			}
			.info {
				display: flex;
				align-items: center;
				.avatar image {
					width: 80rpx;
					height: 80rpx;
					border-radius: 100%;
					margin-right: 20rpx;
				}
				.name {
					font-size: 32rpx;
				}
			}
		}
	}
}
</style>
